FROM satyadeep/php-56-fpm-alpine:latest

ADD ./install-php-extensions /usr/local/bin/

# 国内镜像
RUN sed -i 's/dl-cdn.alpinelinux.org/mirrors.aliyun.com/g' /etc/apk/repositories

RUN apk add --no-cache --virtual .build-deps autoconf tzdata $PHPIZE_DEPS \
        && cp /usr/share/zoneinfo/Asia/Shanghai /etc/localtime \
        && echo "Asia/Shanghai" > /etc/timezone \
        # && pecl install uploadprogress-1.1.4 \
        # https://pecl.php.net/package-changelog.php?package=uploadprogress&release=1.0.3
        # && docker-php-ext-enable uploadprogress \
        && apk del .build-deps autoconf $PHPIZE_DEPS \
    && chmod uga+x /usr/local/bin/install-php-extensions && sync \
    && install-php-extensions bcmath \
            bz2 \
            calendar \
            curl \
            exif \
            fileinfo \
            ftp \
            gd \
            gettext \
            imap \
            intl \
            ldap \
            mbstring \
            mcrypt \
            mysql \
            mysqli \
            opcache \
            pdo \
            pdo_mysql \
            soap \
            sysvsem \
            sysvshm \
            xmlrpc \
            xsl \
            zip \
        #####   Using Xdebug 2.5.5 as support for PHP 5.6 has been dropped in newer versions   #####
        #####   Using Xhprof 0.9.4 as support for PHP 5.X has been dropped in later versions   #####
        #####   Using mongodb 1.7.5 as support for PHP 5.X has been dropped in later versions   #####
        #####   Using memcache 2.2.7 as 3.0.8 won't load even though it installs 
        # and support for PHP 5.X has been dropped in later versions   #####
        &&  echo -e "\n opcache.enable=1 \n opcache.enable_cli=1 \n opcache.memory_consumption=128 \n opcache.interned_strings_buffer=8 \n opcache.max_accelerated_files=4000 \n opcache.revalidate_freq=60 \n opcache.fast_shutdown=1" >> /usr/local/etc/php/conf.d/docker-php-ext-opcache.ini \
        &&  echo -e "\n xdebug.remote_enable=1 \n xdebug.remote_host=localhost \n xdebug.remote_port=9000" >> /usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini \
        &&  echo -e "\n xhprof.output_dir='/var/tmp/xhprof'" >> /usr/local/etc/php/conf.d/docker-php-ext-xhprof.ini \
        && cd ~ \
# Install composer
    && php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');" \
    && php -r "copy('https://composer.github.io/installer.sig', 'signature');" \
    && php -r "if (hash_file('SHA384', 'composer-setup.php') === trim(file_get_contents('signature'))) { echo 'Installer verified'; } else { echo 'Installer corrupt'; unlink('composer-setup.php'); } echo PHP_EOL;" \
    && php composer-setup.php --install-dir=/usr/local/bin --filename=composer \
    && php -r "unlink('composer-setup.php');" \
    && composer config -g repo.packagist composer https://mirrors.aliyun.com/composer/ \
# Install msmtp - To Send Mails on Production & Development
    && apk add msmtp


# 安装其他软件
RUN apk add --no-cache supervisor vim
    
# modify www-data user to have id 1000
# RUN apk add \
#         --no-cache \
#         --repository http://dl-3.alpinelinux.org/alpine/edge/community/ --allow-untrusted \
#         --virtual .shadow-deps \
#         shadow \
#     && usermod -u 1000 www-data \
#     && groupmod -g 1000 www-data \
#     && apk del .shadow-deps

# 工作目录
WORKDIR /www